package com.zbkj.admin.controller;

import com.zbkj.admin.filter.TokenComponent;
import com.zbkj.admin.service.AdminEstimateAiHandleService;
import com.zbkj.admin.service.AdminProjectHandleService;
import com.zbkj.common.model.project.EstimateAi;
import com.zbkj.common.model.project.ReportApplyAudit;
import com.zbkj.common.model.system.SystemAdmin;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.request.project.*;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.UploadResponse;
import com.zbkj.common.response.project.AdminProjectInfoResponse;
import com.zbkj.common.response.project.InformationResponse;
import com.zbkj.common.response.project.ProjectStatusCountResponse;
import com.zbkj.common.response.project.ReportInfoResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Auther:
 * @Date: 2024/7/6 21:57
 * @Description:
 */
/*@Slf4j
@RestController
@RequestMapping("api/admin/project")
@Api(tags = "服务端项目管理服务")*/
public class AdminProjectController {
    /*
    @Autowired
    private AdminProjectHandleService adminProjectHandleService;
    @Resource
    private TokenComponent tokenComponent;
    @Autowired
    private AdminEstimateAiHandleService adminEstimateAiHandleService;

    @ApiOperation(value="获取项目催单数量")
    @GetMapping("/getProjectStatusCount")
    public CommonResult<ProjectStatusCountResponse> getProjectStatusCount() {
        return CommonResult.success(adminProjectHandleService.getProjectStatusCount());
    }

    @ApiOperation(value="项目列表")
    @PostMapping("/list")
    public CommonResult<CommonPage<AdminProjectInfoResponse>> list(@RequestBody AdminProjectQueryRequest queryRequest) {
        return CommonResult.success(CommonPage.restPage(adminProjectHandleService.projectList(queryRequest)));
    }

    @ApiOperation(value="获取项目当前有效源文件列表")
    @GetMapping("/getValidProjectFile/{projectId}")
    public CommonResult<List<InformationResponse>> getValidProjectFileList(@PathVariable("projectId") Long projectId) {
        return CommonResult.success(adminProjectHandleService.getValidProjectFileList(projectId));
    }

    @ApiOperation(value="项目源文件列表")
    @PostMapping("/getProjectFileList")
    public CommonResult<CommonPage<InformationResponse>> getProjectFileList(@RequestBody ProjectFileQueryRequest queryRequest) {
        return CommonResult.success(CommonPage.restPage(adminProjectHandleService.getProjectFileList(queryRequest)));
    }

    @ApiOperation(value="撤回项目")
    @GetMapping("/withdrawProject/{projectId}")
    public CommonResult withdraw(@PathVariable("projectId") Long projectId) {
        adminProjectHandleService.withdrawProject(projectId);
        return CommonResult.success();
    }

    @ApiOperation(value="强制开始估算")
    @GetMapping("/forceEstimateStart/{projectId}")
    public CommonResult forceEstimateStart(@PathVariable("projectId") Long projectId) {
        adminProjectHandleService.forceEstimateStart(projectId);
        return CommonResult.success();
    }

    @ApiOperation(value="项目资料上传")
    @PostMapping("/informationUpload/{type}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type",value = "材料类型：39、采购明细文件，40、功能明细文件，42、编辑后功能点明细文件，43、报告文件"),
    })
    public CommonResult<UploadResponse> informationUpload(@PathVariable("type")Integer type, MultipartFile file) {
        return CommonResult.success(adminProjectHandleService.informationUpload(type,file));
    }

    @ApiOperation(value="项目资料文件提交保存")
    @PostMapping("/informationSave")
    public CommonResult informationSave(@RequestBody @Validated AdminInfomationRequest infomationRequest, HttpServletRequest request) {
        SystemAdmin systemAdmin = tokenComponent.getLoginUser(request).getUser();
        adminProjectHandleService.informationSave(infomationRequest,systemAdmin);
        return CommonResult.success();
    }

    @ApiOperation(value="获取估算结果")
    @GetMapping("/getReportInfo/{projectId}")
    public CommonResult<ReportInfoResponse> getReportInfo(@PathVariable("projectId") Long projectId) {
        return CommonResult.success(adminProjectHandleService.getReportInfo(projectId));
    }

    @ApiOperation(value="估算结果内容保存+上传功能点明细")
    @PostMapping("/reportSave")
    public CommonResult reportSave(@RequestBody @Validated AdminReportRequest reportRequest, HttpServletRequest request) {
        SystemAdmin systemAdmin =  tokenComponent.getLoginUser(request).getUser();
        adminProjectHandleService.projectReportSave(reportRequest, systemAdmin);
        return CommonResult.success();
    }

    @ApiOperation(value="编辑时-获取估算结果内容")
    @GetMapping("/getReportToEdit/{projectId}")
    public CommonResult<ReportInfoResponse> getReportToEdit(@PathVariable("projectId") Long projectId) {
        return CommonResult.success(adminProjectHandleService.getReportToEdit(projectId));
    }

    @ApiOperation(value="估算推送客户端及是否可下载设置")
    @PostMapping("/estimaNotifyClient")
    public CommonResult estimaNotifyClient(@RequestBody @Validated AdminEstimaNotifyClientRequest esNotifyRequest) {
        adminProjectHandleService.estimaNotifyClient(esNotifyRequest);
        return CommonResult.success();
    }

    @ApiOperation(value="获取有效资料对象-下载资料")
    @GetMapping("/getValidInformation/{projectId}/{type}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type",value = "材料类型：39、采购明细文件，40、功能明细文件，41、ai估算结果文件，42、编辑后功能点明细文件， 43、报告文件"),
    })
    public CommonResult<InformationResponse> getValidInformation(@PathVariable("projectId") Long projectId,@PathVariable("type") Integer type) {
        return CommonResult.success(adminProjectHandleService.getValidInformation(projectId, type));
    }
    @ApiOperation(value="项目资料列表查询")
    @PostMapping("/getInformationList")
    public CommonResult<CommonPage<InformationResponse>> getInformationList(@RequestBody @Validated InformationQueryRequest queryRequest) {
        return CommonResult.success(CommonPage.restPage(adminProjectHandleService.getInformationList(queryRequest)));
    }

    @ApiOperation(value="报告申请审核")
    @PostMapping("/reportApplyAudit")
    public CommonResult reportApplyAudit(@RequestBody @Validated AdminReportApplyAuditRequest auditRequest, HttpServletRequest request) {
        SystemAdmin systemAdmin = tokenComponent.getLoginUser(request).getUser();
        adminProjectHandleService.reportApplyAudit(auditRequest, systemAdmin);
        return CommonResult.success();
    }

    @ApiOperation(value="报告申请驳回记录列表")
    @GetMapping("/getReportApplyAuditList/{projectId}")
    public CommonResult<List<ReportApplyAudit>> getReportApplyAuditList(@PathVariable("projectId") Long projectId) {
        return CommonResult.success(adminProjectHandleService.getReportApplyAuditList(projectId));
    }

    @ApiOperation(value="项目密码错误锁定解锁")
    @GetMapping("/unLockProject/{projectId}")
    public CommonResult unLockProject(@PathVariable("projectId") Long projectId) {
        adminProjectHandleService.unLockProject(projectId);
        return CommonResult.success();
    }

    @ApiOperation(value="拆分需求内容提交")
    @PostMapping("/aiContentSubmit")
    public CommonResult aiContentSubmit(@RequestBody @Validated AdminAiContentRequest contentRequest, HttpServletRequest request) {
        SystemAdmin systemAdmin =  tokenComponent.getLoginUser(request).getUser();
        adminProjectHandleService.aiContentSubmit(contentRequest,systemAdmin);
        return CommonResult.success();
    }

    @ApiOperation(value="获取需求拆分内容")
    @GetMapping("/aiContentList/{projectId}")
    public CommonResult<List<EstimateAi>> aiContentList(@PathVariable("projectId") Long projectId) {
        return CommonResult.success(adminProjectHandleService.aiContentList(projectId));
    }


    @ApiOperation(value="估算结果AI回调通知")
    @PostMapping("/estimateAiNotify")
    public CommonResult estimateAiNotify(@RequestBody AiNotifyRequest notifyRequest, HttpServletRequest request) {
        adminEstimateAiHandleService.estimateAiNotify(notifyRequest,request);
        return CommonResult.success();
    }


    @ApiOperation(value="获取项目信息")
    @GetMapping("/getProjectInfo/{projectId}")
    public CommonResult<AdminProjectInfoResponse> getProjectInfo(@PathVariable("projectId") Long projectId) {
        AdminProjectInfoResponse response = adminProjectHandleService.getProjectInfo(projectId);
        return CommonResult.success(response);
    }
    */
}
